<?php

namespace app\api\controller\ai;

use thinkct\controller\Frontend;
use app\admin\model\ai\Config as ConfigModel;
use app\common\model\ai\Nav;
use app\common\model\ai\Models;
use thinkct\facade\ChatAI;

class Web extends Frontend
{
    protected array $noNeedLogin = ['*'];

    public function initialize(): void
    {
        parent::initialize();
    }

    public function getBanner(): void
    {
        $banner = [];
        $this->success('', $banner);
    }

    public function index(): void
    {
        $data = ConfigModel::select();
        $config = [];
        foreach ($data as $k => $v) {
            $config[$v['name']] = $v['value'];
        }

        // 获取Nav
        $nav = Nav::where('status', 1)->select()->toArray();

        $data = [
            'chat' => [
                'title' => $config['ai_chat_title'],
            ],
            'notice' => [
                'show' => $config['notice_show'],
                'title' => $config['notice_title'],
                'content' => $config['notice_content'],
            ],
            'menus' => $nav
        ];


        $this->success('', $data);
    }

    public function chat_config(): void
    {
        $this->success('', [
            'model_list' => ChatAI::getModel()
        ]);
    }
}